package com.example.smartcs.config;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.dashscope.QwenChatModel;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import dev.langchain4j.model.openai.OpenAiChatModel;
import java.time.Duration;

@Configuration
public class LLMConfig {
    
    @Value("${langchain4j.deepseek.api-key:sk-6dfa7b43723a4f7e8d2ba3cea5c4a8c1}")
    private String deepseekApiKey;
    
    @Value("${langchain4j.deepseek.model-name:deepseek-chat}")
    private String deepseekModelName;
    
    @Value("${langchain4j.dashscope.api-key:sk-d2dde5b9c7194691ac02a531f40c84d8}")
    private String dashscopeApiKey;
    
    @Value("${langchain4j.dashscope.model-name:qwen-turbo}")
    private String dashscopeModelName;
    
    /**
     * 配置DeepSeek模型
     */
    @Bean(name = "deepseekModel")
    @Primary
    public ChatLanguageModel deepseekChatLanguageModel() {
        return OpenAiChatModel.builder()
                .apiKey(deepseekApiKey)
                .modelName(deepseekModelName)
                .baseUrl("https://api.deepseek.com/v1")
                .timeout(Duration.ofSeconds(60))
                .logRequests(true)
                .logResponses(true)
                .build();
    }
    
    /**
     * 配置通义千问模型
     */
    @Bean(name = "qwenModel")
    public ChatLanguageModel qwenChatLanguageModel() {
        return QwenChatModel.builder()
                .apiKey(dashscopeApiKey)
                .modelName(dashscopeModelName)
                .build();
    }
} 